/**
 * @modal: 基础功能设置
 */
import CommonModal from '@/components/CommonModal';
import { Button, Space, Popover } from 'antd';
import { useState, useEffect } from "react";
import SubTitle from '@/views/components/SubTitle';
import DownloadModal from '@/pages/Home/component/DownloadModal';
import AddressSet from './AddressSet';
import { useNavigate } from 'react-router-dom';

function BasicSet({ handleCancel }) {

	const [open, setOpen] = useState(false);

	const [visible, setVisible] = useState(false);

	const navigate = useNavigate();

	useEffect(() => {
		setOpen(true);
	}, []);

	//跳转数据
	const handleOpenPage = (val) => {
		navigate(val);
	}

	const onCancel = () => {
		setOpen(false);
	};

	const afterClose = () => {
		handleCancel();
	};

	const DownloadModalProps = {
		handleCancel() {
			setVisible(null);
		}
	}

	return (
		<CommonModal
			title="基础设置"
			afterClose={afterClose}
			open={open}
			width="464px"
			onCancel={onCancel}
			footer={<Button onClick={onCancel}>关闭</Button>}
		>
			<SubTitle wrapStyle={{ margin: '0 0 12px 0' }} symbol as="s2" title="基础管理" />
			<Space size={32} style={{ marginBottom: '16px' }}>
				<Button size='middle' onClick={() => handleOpenPage('/views/basic/qimenStore')} type="default">店铺管理</Button>
				<Button size='middle' onClick={() => setVisible('addressSet')} type="default">管理寄件地址</Button>
			</Space>
			<SubTitle wrapStyle={{ margin: '12px 0 12px 0' }} symbol as="s2" title="快递设置" />
			<Space size={[32, 12]} style={{ marginBottom: '16px' }}>
				<Button size='middle' onClick={() => handleOpenPage('/print/expressAuth')} type="default">快递面单授权</Button>
				<Button size='middle' onClick={() => handleOpenPage('/print/config')} type="default">快递配置</Button>
				{/* <Button size='middle' onClick={() => handleOpenPage('/print/tempErp')} type="default">快递模版</Button> */}
				{/* <Button size='middle' onClick={() => handleOpenPage('/print/expressAuth')} type="default">面单共享</Button> */}
			</Space>
			<SubTitle wrapStyle={{ margin: '12px 0 12px 0' }} symbol as="s2" title="组件" />
			<Space size={32} style={{ marginBottom: '24px' }}>
				<Button size='middle' type="default" onClick={() => setVisible('download')}>打印组件下载</Button>
				<Popover placement='top' trigger={['click']} content={<img src='https://imgniu.zhaojiafang.com/fontWeb/new-app-load.png' style={{ width: 240 }} />}><Button size='middle' type="default">仓储APP下载</Button></Popover>
			</Space>
			{visible == 'download' && <DownloadModal {...DownloadModalProps} />}
			{visible == 'addressSet' && <AddressSet {...DownloadModalProps} />}
		</CommonModal>
	);
}

export default BasicSet;
